<template>
  <div class="app-container">
    <!-- 统一的头部区域 -->
    <header class="app-header">
      <img src="@/assets/danfoss-logo.png" alt="Danfoss Logo" class="logo">
      <h1 class="title">丹佛斯商用压缩机中国实验室制冷剂可视化监控平台</h1>
    </header>

    <!-- 主内容区域 -->
    <main class="app-main">
      <!-- 左侧导航菜单 -->
      <nav class="app-nav">
        <ul class="nav-menu">
          <li 
            class="nav-item" 
            :class="{ active: activeRoute === '/lab-layout' }"
            @click="navigateTo('/lab-layout')"
          >
            <i class="el-icon-s-home"></i>
            <span>实验室布局图</span>
          </li>
          <li 
            class="nav-item"
            :class="{ active: activeRoute === '/warehouse-layout' }"
            @click="navigateTo('/warehouse-layout')"
          >
            <i class="el-icon-office-building"></i>
            <span>制冷剂仓库布局图</span>
          </li>
          <li 
            class="nav-item"
            :class="{ active: activeRoute === '/data-statistics' }"
            @click="navigateTo('/data-statistics')"
          >
            <i class="el-icon-data-analysis"></i>
            <span>数据统计</span>
          </li>
        </ul>
      </nav>

      <!-- 右侧内容区域 -->
      <div class="content-area">
        <router-view></router-view>
      </div>
    </main>
  </div>
</template>

<script>
export default {
  name: 'Layout',
  data() {
    return {
      activeRoute: '/lab-layout'
    }
  },
  created() {
    this.activeRoute = this.$route.path;
  },
  watch: {
    $route(to) {
      this.activeRoute = to.path;
    }
  },
  methods: {
    navigateTo(path) {
      this.$router.push(path);
    }
  }
}
</script>

<style scoped>
/* 基础样式 */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  font-family: 'Helvetica Neue', Arial, sans-serif;
}

/* 头部样式 */
.app-header {
  background-color: #e60012; /* 丹佛斯品牌红色 */
  height: 80px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.logo {
  height: 50px;
  margin-right: 15px;
}

.title {
  color: white;
  font-size: 22px;
  font-weight: bold;
  margin: 0;
  flex-grow: 1;
  text-align: center;
  letter-spacing: 1px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

/* 主内容区域 */
.app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 导航菜单 */
.app-nav {
  width: 200px;
  background-color: #f5f7fa;
  border-right: 1px solid #e6e6e6;
  padding-top: 20px;
  overflow-y: auto;
}

.nav-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  cursor: pointer;
  color: #333;
  font-size: 16px;
  transition: all 0.3s;
}

.nav-item:hover {
  background-color: #ecf5ff;
  color: #409eff;
}

.nav-item.active {
  background-color: #d9ecff;
  color: #409eff;
  font-weight: bold;
  border-left: 4px solid #409eff;
}

.nav-item i {
  margin-right: 10px;
  font-size: 18px;
}

/* 内容区域 */
.content-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background-color: #f0f2f5;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .title {
    font-size: 18px;
  }
  
  .app-nav {
    width: 160px;
  }
  
  .nav-item {
    padding: 0 10px;
    font-size: 14px;
  }
}
</style>